<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-comment">{- |
   Module      :  Media.Win32
   Copyright   :  2012 shelarcy
   License     :  BSD-style

   Maintainer  :  shelarcy@gmail.com
   Stability   :  Provisional
   Portability :  Non-portable (Win32 API)

   Multimedia API. TODO: provide more functions ...
-}</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Media.Win32</span><span>
</span><span id="line-15"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="hs-keyword">module</span><span> </span><span class="annot"><a href="Media.Win32.html"><span class="hs-identifier">Media.Win32</span></a></span><span>
</span><span id="line-16"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>                </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier">unless</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span>               </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier">ioError</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#userError"><span class="hs-identifier">userError</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Error.html#"><span class="hs-identifier">System.IO.Error</span></a></span><span>              </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier">ioError</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#userError"><span class="hs-identifier">userError</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Win32.Encoding.html"><span class="hs-identifier">System.Win32.Encoding</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="System.Win32.Encoding.html#encodeMultiByte"><span class="hs-identifier">encodeMultiByte</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="System.Win32.Encoding.html#getCurrentCodePage"><span class="hs-identifier">getCurrentCodePage</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Win32.Types.html"><span class="hs-identifier">System.Win32.Types</span></a></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Win32.String.html"><span class="hs-identifier">System.Win32.String</span></a></span><span>          </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="System.Win32.String.html#withTStringBufferLen"><span class="hs-identifier">withTStringBufferLen</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">type</span><span> </span><span id="MCIERROR"><span class="annot"><a href="Media.Win32.html#MCIERROR"><span class="hs-identifier hs-var">MCIERROR</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span class="hs-cpp">

#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-28"></span><span class="annot"><a href="Media.Win32.html#mciSendString"><span class="hs-identifier hs-type">mciSendString</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span id="mciSendString"><span class="annot"><span class="annottext">mciSendString :: String -&gt; IO ()
</span><a href="Media.Win32.html#mciSendString"><span class="hs-identifier hs-var hs-var">mciSendString</span></a></span></span><span> </span><span id="local-6989586621679116713"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679116713"><span class="hs-identifier hs-var">cmd</span></a></span></span><span>
</span><span id="line-30"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; (LPTSTR -&gt; IO ()) -&gt; IO ()
forall a. String -&gt; (LPTSTR -&gt; IO a) -&gt; IO a
</span><a href="System.Win32.Types.html#withTString"><span class="hs-identifier hs-var">withTString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679116713"><span class="hs-identifier hs-var">cmd</span></a></span><span> </span><span class="annot"><span class="annottext">((LPTSTR -&gt; IO ()) -&gt; IO ()) -&gt; (LPTSTR -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679116711"><span class="annot"><span class="annottext">LPTSTR
</span><a href="#local-6989586621679116711"><span class="hs-identifier hs-var">sendCmd</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-31"></span><span>     </span><span id="local-6989586621679116710"><span class="annot"><span class="annottext">MCIERROR
</span><a href="#local-6989586621679116710"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LPTSTR -&gt; LPTSTR -&gt; MCIERROR -&gt; HANDLE -&gt; IO MCIERROR
</span><a href="Media.Win32.html#c_mciSendString"><span class="hs-identifier hs-var">c_mciSendString</span></a></span><span> </span><span class="annot"><span class="annottext">LPTSTR
</span><a href="#local-6989586621679116711"><span class="hs-identifier hs-var">sendCmd</span></a></span><span> </span><span class="annot"><span class="annottext">LPTSTR
forall a. Ptr a
</span><a href="../../base/src/GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">MCIERROR
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">HANDLE
forall a. Ptr a
</span><a href="../../base/src/GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-32"></span><span>     </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MCIERROR
</span><a href="#local-6989586621679116710"><span class="hs-identifier hs-var">err</span></a></span><span> </span><span class="annot"><span class="annottext">MCIERROR -&gt; MCIERROR -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">MCIERROR
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span>       </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MCIERROR -&gt; IO ()
</span><a href="Media.Win32.html#mciGetErrorString"><span class="hs-identifier hs-var">mciGetErrorString</span></a></span><span> </span><span class="annot"><span class="annottext">MCIERROR
</span><a href="#local-6989586621679116710"><span class="hs-identifier hs-var">err</span></a></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">safe</span><span> </span><span class="hs-string">&quot;windows.h mciSendStringW&quot;</span><span>
</span><span id="line-36"></span><span>  </span><span id="c_mciSendString"><span class="annot"><a href="Media.Win32.html#c_mciSendString"><span class="hs-identifier hs-var">c_mciSendString</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Win32.Types.html#LPCTSTR"><span class="hs-identifier hs-type">LPCTSTR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Win32.Types.html#LPTSTR"><span class="hs-identifier hs-type">LPTSTR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Win32.Types.html#UINT"><span class="hs-identifier hs-type">UINT</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Win32.Types.html#HANDLE"><span class="hs-identifier hs-type">HANDLE</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="Media.Win32.html#MCIERROR"><span class="hs-identifier hs-type">MCIERROR</span></a></span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="annot"><a href="Media.Win32.html#mciGetErrorString"><span class="hs-identifier hs-type">mciGetErrorString</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Media.Win32.html#MCIERROR"><span class="hs-identifier hs-type">MCIERROR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span id="mciGetErrorString"><span class="annot"><span class="annottext">mciGetErrorString :: MCIERROR -&gt; IO ()
</span><a href="Media.Win32.html#mciGetErrorString"><span class="hs-identifier hs-var hs-var">mciGetErrorString</span></a></span></span><span> </span><span id="local-6989586621679116704"><span class="annot"><span class="annottext">MCIERROR
</span><a href="#local-6989586621679116704"><span class="hs-identifier hs-var">err</span></a></span></span><span>
</span><span id="line-40"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ((LPTSTR, Int) -&gt; IO ()) -&gt; IO ()
forall a. Int -&gt; ((LPTSTR, Int) -&gt; IO a) -&gt; IO a
</span><a href="System.Win32.String.html#withTStringBufferLen"><span class="hs-identifier hs-var">withTStringBufferLen</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">256</span></span><span> </span><span class="annot"><span class="annottext">(((LPTSTR, Int) -&gt; IO ()) -&gt; IO ())
-&gt; ((LPTSTR, Int) -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679116703"><span class="annot"><span class="annottext">LPTSTR
</span><a href="#local-6989586621679116703"><span class="hs-identifier hs-var">cstr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679116702"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679116702"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="hs-keyword">do</span><span>
</span><span id="line-41"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; IO Bool -&gt; IO ()
</span><a href="System.Win32.Types.html#failIfFalse_"><span class="hs-identifier hs-var">failIfFalse_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[String] -&gt; String
</span><a href="../../base/src/Data.OldList.html#unwords"><span class="hs-identifier hs-var">unwords</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mciGetErrorString&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MCIERROR -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">MCIERROR
</span><a href="#local-6989586621679116704"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO Bool -&gt; IO ()) -&gt; IO Bool -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><span class="annottext">MCIERROR -&gt; LPTSTR -&gt; MCIERROR -&gt; IO Bool
</span><a href="Media.Win32.html#c_mciGetErrorString"><span class="hs-identifier hs-var">c_mciGetErrorString</span></a></span><span> </span><span class="annot"><span class="annottext">MCIERROR
</span><a href="#local-6989586621679116704"><span class="hs-identifier hs-var">err</span></a></span><span> </span><span class="annot"><span class="annottext">LPTSTR
</span><a href="#local-6989586621679116703"><span class="hs-identifier hs-var">cstr</span></a></span><span> </span><span class="annot"><span class="annottext">(MCIERROR -&gt; IO Bool) -&gt; MCIERROR -&gt; IO Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; MCIERROR
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679116702"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-43"></span><span>      </span><span id="local-6989586621679116697"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679116697"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LPTSTR -&gt; IO String
</span><a href="System.Win32.Types.html#peekTString"><span class="hs-identifier hs-var">peekTString</span></a></span><span> </span><span class="annot"><span class="annottext">LPTSTR
</span><a href="#local-6989586621679116703"><span class="hs-identifier hs-var">cstr</span></a></span><span>
</span><span id="line-44"></span><span>      </span><span id="local-6989586621679116695"><span class="annot"><span class="annottext">MCIERROR
</span><a href="#local-6989586621679116695"><span class="hs-identifier hs-var">cp</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO MCIERROR
</span><a href="System.Win32.Encoding.html#getCurrentCodePage"><span class="hs-identifier hs-var">getCurrentCodePage</span></a></span><span>
</span><span id="line-45"></span><span>      </span><span class="annot"><span class="annottext">IOError -&gt; IO ()
forall a. IOError -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioError"><span class="hs-identifier hs-var">ioError</span></a></span><span> </span><span class="annot"><span class="annottext">(IOError -&gt; IO ()) -&gt; IOError -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; IOError
</span><a href="../../base/src/GHC.IO.Exception.html#userError"><span class="hs-identifier hs-var">userError</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; IOError) -&gt; String -&gt; IOError
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MCIERROR -&gt; String -&gt; String
</span><a href="System.Win32.Encoding.html#encodeMultiByte"><span class="hs-identifier hs-var">encodeMultiByte</span></a></span><span> </span><span class="annot"><span class="annottext">MCIERROR
</span><a href="#local-6989586621679116695"><span class="hs-identifier hs-var">cp</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679116697"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h mciGetErrorStringW&quot;</span><span>
</span><span id="line-48"></span><span>  </span><span id="c_mciGetErrorString"><span class="annot"><a href="Media.Win32.html#c_mciGetErrorString"><span class="hs-identifier hs-var">c_mciGetErrorString</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Media.Win32.html#MCIERROR"><span class="hs-identifier hs-type">MCIERROR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Win32.Types.html#LPTSTR"><span class="hs-identifier hs-type">LPTSTR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Win32.Types.html#UINT"><span class="hs-identifier hs-type">UINT</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Win32.Types.html#BOOL"><span class="hs-identifier hs-type">BOOL</span></a></span><span>
</span><span id="line-49"></span></pre></body></html>